﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common.Logging;
using WuDada.Core.Post;
using WuDada.Core.Post.Service;
using WuDada.Core.Post.Domain;

public partial class products : System.Web.UI.Page
{
    private PostFactory m_PostFactory;
    private IPostService m_PostService;

    //商品分類NodeId=3
    private int m_ProductNodeId = 3;

    private int m_NodeId = 0;
    private string m_ProductsPath = "products.aspx";

    protected void Page_Load(object sender, EventArgs e)
    {
        m_PostFactory = new PostFactory();
        m_PostService = m_PostFactory.GetPostService();
        m_NodeId = QueryStringHelper.GetInteger("node", 0);            

        if (!IsPostBack)
        {            
            fillRepeaterProductSubs();
            LoadDataToUI();
        }
    }    

    private void LoadDataToUI()
    {
        NodeVO nodeVO = m_PostService.GetNodeById(m_NodeId);
        if (nodeVO != null)
        {
            ltlTitle.Text = nodeVO.Name;
            ltlTitle2.Text = nodeVO.Name;
        }
    }

    private void fillRepeaterProductSubs()
    {
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("KeyWord", txtKeyWord.Text.Trim());
        conditions.Add("NodeId", m_NodeId.ToString());
        conditions.Add("Flag", "1");
        RepeaterProductsSubs2.DataSource = m_PostService.GetPostList(conditions);
        RepeaterProductsSubs2.DataBind();
    }

    protected void btnQuery_Click(object sender, ImageClickEventArgs e)
    {
        fillRepeaterProductSubs();
    }
}